package com.sohu.peak.gallery.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

import com.sohu.peak.util.Logger;

/**
 * Tags entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class Tag implements java.io.Serializable {

	// Fields
	private static Logger log = new Logger();
	private Long id;
	private String tagName;
	private Long tagType;
	private Long cateId;
	private Long tagPrority;
	private Long tagHot;
    private Category category;
    private String cates;
    private Date tagCtime;
	private Category topFcate;
    private List<Category> cateList=new ArrayList<Category>();
    private Set<TagGroup> tagGroups = new java.util.HashSet<TagGroup>();
    private Set<PicGroup> picGroups =new java.util.HashSet<PicGroup>();
	// Constructors
	private List<Long> categoryId;
	public Category getCategory() {
		return category;
	}

	public Long getCateId() {
		return cateId;
	}

	public void setCateId(Long cateId) {
		this.cateId = cateId;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	/** default constructor */
	public Tag() {
	}

	/** minimal constructor */
	public Tag(Long id, Long tagPrority) {
		this.id = id;
		this.tagPrority = tagPrority;
	}

	/** full constructor */
	public Tag(Long id, String tagName, Long tagType, Long tagPrority) {
		this.id = id;
		this.tagName = tagName;
		this.tagType = tagType;
		this.tagPrority = tagPrority;
	}

	// Property accessors

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTagName() {
		return this.tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public Long getTagType() {
		return this.tagType;
	}

	public void setTagType(Long tagType) {
		this.tagType = tagType;
	}

	public Long getTagPrority() {
		return this.tagPrority;
	}

	public void setTagPrority(Long tagPrority) {
		this.tagPrority = tagPrority;
	}

	
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }

	public Long getTagHot() {
		return tagHot;
	}

	public void setTagHot(Long tagHot) {
		this.tagHot = tagHot;
	}

	public String getCates() {
		return cates;
	}

	public void setCates(String cates) {
		this.cates = cates;
	}

	public List<Category> getCateList() {
		if (cateList == null) {
			if (this.cates != null && !this.cates.equals("")) {
				String[] cid = cates.split("[|]");
				cateList = new ArrayList();
				for (String cd : cid) {
					if("".equals(cd)||"null".equals(cd))
						continue;
					try{
						Category cate = new Category();
						cate.setId(Long.parseLong(cd));
						cateList.add(cate);
					}catch(NumberFormatException nfe){
						log.error("cateId %s parseLong error:%s",cd,nfe.getMessage());
					}
				}
			}

		}
		return cateList;
	}
	public String getTagAuthorCategoryId() {
		if (this.cates != null && !this.cates.equals("")) {
			String[] cids = this.cates.split("[|]");
			if (cids != null) {
				for (String cid : cids) {
					if (StringUtils.isNotEmpty(cid)&&!cid.equals("null")) {
						return cid;
					}
				}
			}

		}
		return "";
	}
	public void setCateList(List<Category> cateList) {
		this.cateList = cateList;
	}

	public void setTagGroups(Set<TagGroup> tagGroups) {
		this.tagGroups = tagGroups;
	}

	public Set<TagGroup> getTagGroups() {
		return tagGroups;
	}

	public void setTopFcate(Category topFcate) {
		this.topFcate = topFcate;
	}

	public List<Long> getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(List<Long> categoryId) {
		this.categoryId = categoryId;
	}

	public Set<PicGroup> getPicGroups() {
		return picGroups;
	}

	public void setPicGroups(Set<PicGroup> picGroups) {
		this.picGroups = picGroups;
	}

	public Date getTagCtime() {
		return tagCtime;
	}

	public void setTagCtime(Date tagCtime) {
		this.tagCtime = tagCtime;
	}
	
}